<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/4
 * Time: 11:58
 */

namespace App\Http\Controllers\Home;


use App\News;
use App\NewsCategory;
use App\Services\GoodsCategoryService;
use App\Services\NewsService;
use Symfony\Component\HttpFoundation\Request;

class ArticleController extends BaseController
{
    private $categoryService = null;
    private $newsCategoryService = null;
    private $newsService = null;

    public function __construct(GoodsCategoryService $categoryService,
                                NewsCategory $newsCategoryService,
                                NewsService $newsService
    )
    {
        parent::__construct($categoryService);
        $this->newsCategoryService = $newsCategoryService;
        $this->categoryService     = $categoryService;
        $this->newsService         = $newsService;
    }

    public function activityList()
    {
        $actList = $this->newsService->actList();
        return view('home.consulting.activity', [
            'title'    => '促销活动',
            'show'     => true,
            'cates'    => $this->all_cate,
            'act_list' => $actList
        ]);
    }

    public function activityDetail(Request $request)
    {
        $id        = $request->id;
        $actDetail = $this->newsService->actDetail($id);
        return view('home.consulting.activityDetail', [
            'title'      => '促销活动',
            'show'       => false,
            'cates'      => $this->all_cate,
            'act_detail' => $actDetail
        ]);
    }

    public function technical(Request $request)
    {
        return view('home.consulting.technical', [
            'title'    => '促销活动',
            'show'     => true,
            'cates'    => $this->all_cate,
            'tec_list' => ''
        ]);
    }

    /**
     * @description:文章列表
     * @author: hkw <hkw925@qq.com>
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function article_list()
    {
        $article_list = $this->newsService->articleList(NewsCategory::$DEFAULT_CATE_JSWZ);
        return view('home.article.article_list', [
            'title'   => '技术文章',
            'cates'   => $this->all_cate,
            'article' => $article_list
        ]);
    }

    public function article_detail(Request $request)
    {
        $id = $request->id;
        $articleInfo = $this->newsService->articleDetail($id);
        return view('home.article.article_detail',[
            'title'   => '技术文章',
            'cates'   => $this->all_cate,
            'article_info'  =>  $articleInfo
        ]);
    }
}